package com.breaker.kata.leetcode;

public class LastWordLength {

    public int lengthOfLastWord(String s) {
        int result = 0;
        for (int i = s.length() - 1; i >= 0; i--) {
            if (s.charAt(i) != ' ') {
                result++;
            } else if (result > 0) {
                return result;
            }
        }
        return result;
    }
}
